package com.tanhua.server.service;

import com.alibaba.fastjson.JSON;
import com.tanhua.domain.mongo.Comment;
import com.tanhua.server.interceptors.UserHolder;
import org.checkerframework.checker.units.qual.A;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class MqService {
    @Autowired
    private RabbitTemplate rabbitTemplate;



    public void sendMsgToMq(String videoId, int type) {

        Map map = new HashMap<>();
        map.put("userId", UserHolder.getUserId());
        map.put("videoId", videoId);
        map.put("type", type);
        String jsonString = JSON.toJSONString(map);
        rabbitTemplate.convertAndSend("video.score.exchange", "video.score", jsonString);
    }
    }

